<template>
  <div>
    <customDetailsTopbar title="环境风险点详情" flag @back="back" />
    <div class="d-scroll listInner px-1">
      <div class="py-1 px-1 bg-white">
        <div v-for="(item, index) in descList" :key="index">
          <div>
            <custom-details-item :icon="item.icon" :label="item.label" :value="item.value" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import customDetailsItem from '@/components/globals/custom-details-item.vue'
import { HbGetCompanyRiskList } from '@/api/environment'
import CustomDetailsTopbar from '@/components/globals/custom-details-topbar.vue'

export default {
  components: { CustomDetailsTopbar, customDetailsItem },
  data() {
    return {
      form: {
        pageNum: 1,
        pageSize: 10,
        companyId: '',
        riskLevel: '',
        riskName: '',
        substanceType: ''
      },
      descList: [
        { label: '企业名称', fieldName: 'companyName', value: '/', icon: '&#xe790;' },
        { label: '风险点名称', fieldName: 'riskName', value: '/', icon: '&#xe72e;' },
        { label: '风险点位置', fieldName: 'riskAddr', value: '/', icon: '&#xe87e;' },
        { label: '风险物质', fieldName: 'substance', value: '/', icon: '&#xe69e;' },
        { label: '风险物质类型', fieldName: 'substanceType', value: '/', icon: '&#xe791;' },
        { label: '风险物资存储量（吨）', fieldName: 'storageValue', value: '/', icon: '&#xe633;' },
        { label: '风险物质最大存储量（吨）', fieldName: 'storageMaxValue', value: '/', icon: '&#xe633;' },
        { label: '风险物质临界量（吨）', fieldName: 'storageLimitValue', value: '/', icon: '&#xe633;' },
        { label: '责任人', fieldName: 'headUser', value: '/', icon: '&#xe700;' },
        { label: '联系方式', fieldName: 'phone', value: '/', icon: '&#xe60a;' }
      ]
    }
  },
  mounted() {
    const { current, riskName } = this.$route.query
    this.current = current || ''
    this.form.riskName = riskName || ''
    // this.HbGetCompanyRiskList()
    this.descList.forEach((v) => {
      v.value = this.$route.query[v.fieldName] !== '' ? this.$route.query[v.fieldName] : '/'
    })
  },
  methods: {
    back() {
      this.$router.push({
        path: '/staging/pollutionSources',
        query: { current: this.current }
      })
    },
    async HbGetCompanyRiskList() {
      const { status, data } = await HbGetCompanyRiskList(this.form)
      if (status === 0 && data) {
        this.descList.forEach((v) => {
          v.value = data.list[0][v.fieldName] !== '' ? data.list[0][v.fieldName] : '/'
        })
      }
    }
  }
}
</script>
